package day09.LinkedListTest;

import java.util.Iterator;
import java.util.LinkedList;

public class Test2 {
    public static void main(String[] args) {
        // 准备集合
        LinkedList<String> list1 = new LinkedList<>();
        for(int i = 0; i < 100000; i++){
            list1.add("a");
        }
        System.out.println(list1.size());
        System.out.println("---------------");
        long t = System.currentTimeMillis();
        f1(list1);
        t = System.currentTimeMillis() - t;
        System.out.println(t);
        System.out.println("---------------");
        t = System.currentTimeMillis();
        f2(list1);
        t = System.currentTimeMillis() - t;
        System.out.println(t);
    }

    private static void f1(LinkedList<String> list1) {

        for(int i = 0; i < list1.size(); i++){
            String s1 = list1.get(i);
        }


    }

    private static void f2(LinkedList<String> list1) {
        Iterator<String> it = list1.iterator();

        while(it.hasNext()){
            it.next();
        }
    }


}
